package example1;

import java.util.Scanner;

public class BuyCoffer {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.println("订购咖啡程序\n");
		System.out.println("1)美式咖啡(100元) 2)拿铁(200元) 3)结算 4)结束");
		System.out.print("请选择：");
		int select = input.nextInt();
		int Americano = 0;
		int latte = 0;
		
		loop:
		while(true)
		{
			switch(select)
			{
				case 1: 
					System.out.println("订购一杯美式咖啡\n");
					Americano++;
					break;
				case 2:
					System.out.println("订购一杯拿铁\n");
					latte++;
					break;
				case 3:
					for(int i=0; i<10; i++) {
						System.out.print("=");
					}
					System.out.println("\n  结算金额");
					for(int i=0; i<10; i++) {
						System.out.print("=");
					}
					System.out.println();
					
					if(Americano > 0) {
						System.out.println("美式咖啡 " + Americano + "杯 " + Americano * 100 + "元");
					}
					if(latte > 0) {
						System.out.println("拿铁 " + latte + "杯 " + latte * 200 + "元");
					}
					for(int i=0; i<10; i++) {
						System.out.print("=");
					}
					
					System.out.println("\n 一共" + ((Americano * 100) + (latte * 200)) + "元");
					for(int i=0; i<10; i++) {
						System.out.print("=");
					}
					
					System.out.println("\n完成结算");
					break loop;
				case 4: 
					break loop;
				default:
					System.out.println("请输入正确的数字0~4");
					break;
			}
			
			System.out.println("1)美式咖啡(100元) 2)拿铁(200元) 3)结算 4)结束");
			System.out.print("请选择：");
			select = input.nextInt();
		}
		
		System.out.println("结束咖啡订购，再见!");
		input.close();
	}
}
